window.addEventListener('load', function () {
    var long = document.querySelector('.long');
    var short = document.querySelector('.short');
    var cha = document.getElementById('cha'); 
    // console.log(cha);
    cha.addEventListener('click', function () {
        if (long.value == '' && short.value == '') {
            alert('请输入新昵称和效验码');
        } else if (long.value == '') {
            alert('请输入新昵称');
        } else if (short.value == '' || short.value !== 'kdfja') {
            alert('请输入正确的效验码');
        } else {
            window.location.href = 'index.html';
            localStorage.setItem('uunam', long.value);
            localStorage.setItem('nnum', short.value);
            alert('提交成功');
        }
    })
    // 首页获取并显示登录页面数据start
    var personA = document.getElementById('personA');
    // personA.addEventListener('mouseover', function () {
    //     personH.style.display = 'block';
    // });
    var dataU = localStorage.getItem('username');
    var datap = localStorage.getItem('password');
    // console.log( $("#user").text());
    var user = document.getElementById('user');
    if (user == "null") {
        user.innerHTML = '个人中心';
        
    } else {
        user.innerHTML = '欢迎 ' + dataU + '！';
    }
    // 首页获取并显示数据end



    // 首页获取并显示个人中心页面数据start
    var qqi = document.querySelector('.qqi');
    var qqLogin = document.querySelector('.qqLogin');
    var dataCe = localStorage.getItem('uunam');
    var username = dataCe;
    // console.log(username);
    localStorage.setItem('username',username);
    if (dataCe != '') {
        qqLogin.innerHTML = dataCe;
    } else {
        qqLogin.innerHTML = 'qq_login';
    }
    // 首页获取并显示个人中心页面数据end

    // 修改qq图像start
    var imgS = localStorage.getItem('images/index/椭圆 12 拷贝.png');
    qqi.src = imgS;
    // 修改qq图像end

})
